package demo3;

public class Computer {
    public void powerOn() {
        System.out.println("打开电脑");
    }
    public void powerOff() {
        System.out.println("关闭电脑");
    }
    public void usbService(IUSB iusb) {
        iusb.openService();
        if(iusb instanceof Mouse) {
            Mouse mouse = (Mouse) iusb;
            //Mouse mouse = new Mouse();
            mouse.click();
        }else if(iusb instanceof KeyBoard) {
            KeyBoard keyboard = (KeyBoard) iusb;
            //KeyBoard keyboard = new KeyBoard();
            keyboard.input();
        }
        iusb.closeService();
    }
}
